def Afun():
    return 'A'

# from ..B.B import Bfun
# ValueError: attempted relative import beyond top-level package

# from importrules.B.B import Bfun
# ModuleNotFoundError: No module named 'importrules'

# from .B.B import Bfun
# ModuleNotFoundError: No module named 'A.B'

# /root/MyCode/importrules/B
# export PYTHONPATH=/root/MyCode/importrules/B:$PYTHONPATH
from mypackage.B.B import Bfun
def fromAgetB():
    return Bfun

# from mypackage.C.D.D import Dfun
from ..C.D.D import Dfun
def fromAgetD():
    return Dfun